package csu.web.jpetstore.web.servlet;

import csu.web.jpetstore.domain.Order;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ShippingViewServlet extends HttpServlet {

    private static final String CONFIRM_ORDER_FORM = "/WEB-INF/jsp/order/confirmOrderView.jsp";
    private static final String SHIPPING_FORM = "/WEB-INF/jsp/order/shippingView.jsp";

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session =req.getSession();

        Order order = (Order) session.getAttribute("order");
        order.setCardType(req.getParameter("order.creditCardType"));
        order.setCreditCard(req.getParameter("order.creditCard"));
        order.setExpiryDate(req.getParameter("order.expiryDate"));
        order.setBillToFirstName(req.getParameter("order.billToFirstName"));
        order.setBillToLastName(req.getParameter("order.billToLastName"));
        order.setBillAddress1(req.getParameter("order.billAddress1"));
        order.setBillAddress2(req.getParameter("order.billAddress2"));
        order.setBillCity(req.getParameter("order.billCity"));
        order.setBillState(req.getParameter("order.billState"));
        order.setBillZip(req.getParameter("order.billZip"));
        order.setBillState(req.getParameter("order.billState"));
        order.setBillCountry(req.getParameter("order.billCountry"));

        String[] chk = req.getParameterValues("shippingAddressRequired");
            req.getRequestDispatcher(SHIPPING_FORM).forward(req,resp);
    }
}
